﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Extensions;
using ConfExpert.Utility;
using DevExpress.Utils;

namespace Tailord
{
    public partial class KumasSiparisleri : XForm
    {
        public KumasSiparisleri()
        {
            InitializeComponent();
        }

        private void KesilenKumaslar_Load(object sender, EventArgs e)
        {
            MainToolbar.Visible = true;
            this.Text = "Kumaş Tedarik";

            gvKumas.Init("GetKumasSiparisleri","TAILORD");

            gvKumas.FormatAsDate("FoyTarihi", "KumasSiparisTarihi");
            gvKumas.FormatAsNumber(2, "KumasSiparisMetraji");
            gvKumas.AddSummary("KumasSiparisMetraji");

            gvKumas.MakeReadOnly();
            gvKumas.BestFitColumns();

            bbiGuncelle.ItemClick += bbiGuncelle_ItemClick;
            gvKumas.RowCellStyle += gvKumas_RowCellStyle;
        }

        void gvKumas_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            if (e.RowHandle > -1)
            {
                if (e.Column.FieldName == "KumasKodu")
                {
                    e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                    e.Appearance.ForeColor = Color.Green;
                }
                else if (e.Column.FieldName == "KumasSiparisMetraji")
                {
                    e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                }
                else if (e.Column.FieldName == "Tutar")
                {
                    e.Appearance.Font = new Font(AppearanceObject.DefaultFont, FontStyle.Bold);
                    e.Appearance.ForeColor = Color.Red;
                }
            }
        }

        void bbiGuncelle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvKumas.VeriyiGuncelle("GetKumasSiparisleri", "TAILORD");
        }
    }
}
